package com.yict.csms.resourceplan.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yict.common.service.impl.BaseServiceImpl;
import com.yict.csms.resourceplan.dao.ICarQcNeedhourDao;
import com.yict.csms.resourceplan.entity.CarQcNeedhour;
import com.yict.csms.resourceplan.service.ICarQcNeedhourService;

@Service("carQcNeedhourService")
public class CarQcNeedhourServiceImpl extends BaseServiceImpl<CarQcNeedhour, Long, ICarQcNeedhourDao> implements ICarQcNeedhourService {

	@Resource(name = "carQcNeedhourDao")
	public void setBaseDao(ICarQcNeedhourDao baseDao) {
		super.setBaseDao(baseDao);
	}

	@Override
	public List<CarQcNeedhour> findByQCNo(List<String> qcNo) {
		List<CarQcNeedhour> list = new ArrayList<CarQcNeedhour>();
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuilder hql = new StringBuilder("from CarQcNeedhour t where 1=1");
		if(qcNo != null && !qcNo.isEmpty() && qcNo.size() > 0) {
			hql.append(" and t.qcno in (:qcNo)");
			map.put("qcNo", qcNo);
		}
		list = this.getBaseDao().list(hql.toString(), map, 0, 0);
		return list;
	}

	@Override
	public List<CarQcNeedhour> findByTimeId(Long timeid) {
		List<CarQcNeedhour> list = new ArrayList<CarQcNeedhour>();
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuilder hql = new StringBuilder("from CarQcNeedhour t where 1=1");
		if(timeid != null) {
			hql.append(" and t.carTime.timeid = :timeid");
			map.put("timeid", timeid);
		}
		list = this.getBaseDao().list(hql.toString(), map, 0, 0);
		return list;
	}
}
